perm filename QUAD.SAI[1,DEK]1 blob sn#518703 filedate 1980-07-02 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	begin comment test distribution of partial quotients in quadratics
C00004 ENDMK
C⊗;
begin comment test distribution of partial quotients in quadratics;
integer d,dd,n;
integer array count[0:100];
label printit;
external procedure bail;
setprint("","b");
arrclr(count);
bail;
for dd←319 step 1 until 2000000000 do
	begin integer t,rr,u,uu,v,vv,a,m;
	u←uu←rr←2000000000; v←dd; vv←1; m←0;
	while v≠1 do
		begin a←u div v; uu←u; u←rr-(u mod v);
		n←n+1; m←m+1;
		if a>100 then count[0]←count[0]+1 else count[a]←count[a]+1;
		if n=1000000 then go to printit;
		t←v; v←a*(uu-u)+vv; vv←t;
		end;
	print('15&'12,"sqrt(10↑18 +",dd,") cycle length ",m);
	end;
printit:
for d←0 step 1 until 100 do print('15&'12,d,": ",count[d]);
end